<template>
	<view class="fillBox">
		<view class="title">
			数据填报
		</view>
		<!-- 填报内容 -->
		<view class="fillContent">
			<view class="fillContentBox">
				<view class="numType">
					<view class="numType1">
						数据类型:
					</view>
					<view class="numType2">
						客户数据
					</view>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBox">
					<view class="nameBox1">
						姓名:
					</view>
					<input type="text" v-model="form.name" class="nameBox2"  placeholder="请输入姓名"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBox">
					<view class="nameBox1">
						性别:
					</view>
					<input type="text" v-model="gender" @input="onInput" class="nameBox2"  placeholder="请输入性别"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBox">
					<view class="nameBox1">
						年龄:
					</view>
					<input type="text" v-model="form.age" class="nameBox2"  placeholder="请输入年龄"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBox">
					<view class="nameBox1">
						电话:
					</view>
					<input type="text" v-model="form.mobile" class="nameBox2"  placeholder="请输入手机号"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBox">
					<view class="nameBox1">
						预算:
					</view>
					<input type="text" v-model="form.budget" class="nameBox2"  placeholder="请输入您的预算"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBoxa">
					<view class="nameBoxa1">
						意向车型:
					</view>
					<input type="text" v-model="form.cat_type" class="nameBoxa2"  placeholder="请输入购买的车型"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBox">
					<view class="nameBox1">
						颜色:
					</view>
					<input type="text" v-model="form.colour" class="nameBox2"  placeholder="请输入您选择的颜色"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="nameBox">
					<view class="nameBox1">
						用途:
					</view>
					<input type="text" v-model="form.purpose" class="nameBox2"  placeholder="请输入您的用途"/>
				</view>
				<view class="wire">
					
				</view>
				<view class="remarks">
					<view class="remarks1">
						备注:
					</view>
					<textarea class="remarks2" v-model="form.remark" placeholder="请输入备注" />
				</view>
				<view class="wire">
					
				</view>
				<view class="btn" @click="submitClick">
					确定提交
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import {fillIn} from '@/request/api.js'
	export default {
		data() {
			return {
				gender:'',
				form:{
					type:2,
					name:'',//姓名
					mobile:'',
					cat_type:'',//购买车型
					remark:'', //备注
					gender:'',//性别
					age:'',//年龄
					budget:'',//预算
					colour:'',//颜色
					purpose:'',//用途
					distributor_id:'',
					regional_id:'',
				}
				
			};
		},
		onLoad() {
			this.form.distributor_id = uni.getStorageSync("login").id
			this.form.regional_id = uni.getStorageSync("login").regional_id
		},
		onShow() {
			
		},
		methods:{
			submitClick(){
				let _this = this
				if(_this.name==''||_this.mobile==''||_this.cat_type==''||_this.remark==''||_this.gender==''||_this.age==''||_this.budget==''||_this.colour==''||_this.purpose==''){
					uni.showToast({
						title:"请填写完整信息",
						icon:"none"
					})
					return
				}
				fillIn(_this.form).then(res => {
					console.log(res);
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
					if(res.code == 1){
						setTimeout(()=>{
							uni.reLaunch({
								url:"/pages/DLR/dataManagement/dataManagement?id=2"
							})
						},2000)
					}
				})
				
			},
			onInput(e){
				console.log(e.detail.value);
				if(e.detail.value == "男"){
					this.form.gender = 1
				}else if(e.detail.value == "女"){
					this.form.gender = 2
				}
			}
		}
	}
</script>

<style lang="scss">
page{
		background-color: #FFFFFF;
	}
	.fillBox{
		width: 100%;
		box-sizing: border-box;
		padding-bottom: 40rpx;
		overflow: hidden;
		position: relative;
		.title{
			width: 100%;
			text-align: center;
			margin-top: 54rpx;
			font-size: 38rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #313233;
		}
		.fillContent{
			width: 100%;
			overflow: hidden;
			.fillContentBox{
				width: 622rpx;
				margin: 30rpx auto 0;
				.numType{
					width: 100%;
					display: flex;
					overflow: hidden;
					.numType1{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
						margin-right: 80rpx;
					}
					.numType2{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
					}
				}
				
				.wire{
					width: 100%;
					height: 4rpx;
					background-color:#e9e9ec;
					margin-top: 28rpx;
				}
				.nameBox{
					width: 100%;
					display: flex;
					overflow: hidden;
					margin-top: 40rpx;
					.nameBox1{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
						margin-right: 156rpx;
					}
					.nameBox2{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
						flex: 1;
					}
				}
				.nameBoxa{
					width: 100%;
					display: flex;
					overflow: hidden;
					margin-top: 40rpx;
					.nameBoxa1{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
						margin-right: 84rpx;
					}
					.nameBoxa2{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
						flex: 1;
					}
				}
				.remarks{
					width: 100%;
					display: flex;
					overflow: hidden;
					margin-top: 40rpx;
					.remarks1{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: 500;
						margin-right: 150rpx;
					}
					.remarks2{
						width: 386rpx;
						height: 230rpx;
						border: 1px solid #e9e9ec;
					}
				}
				.btn{
					width: 460rpx;
					height: 80rpx;
					background: #1855F6;
					border-radius: 40rpx;
					// margin-top: 122rpx;
					margin: 122rpx auto 0;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
					line-height: 80rpx;
					text-align: center;
				}
			}
		}
	}
</style>
